from mysql_conf import mysel_conf
conn = mysel_conf.pool()
cursor = conn.cursor()
def get_id_for_14():
    sql = "SELECT id FROM contents  where contents_refter_type='14' "
    cursor.execute(sql)
    res = cursor.fetchall()
    return res
def get_content_id_to_ext(id):
    sql = f"SELECT * FROM contents_ext  where contents_id= { id }"
    cursor.execute(sql)
    res = cursor.fetchone()
    return res
def update_14_to_media_type_4(id):
    update_sql = f"UPDATE  contents  SET media_type = 4 WHERE id={ id }"
    cursor.execute(update_sql)
    conn.commit()
def update_14_to_media_type_1(id):
    update_sql = f"UPDATE  contents  SET media_type = 1 WHERE id={ id }"
    cursor.execute(update_sql)
    conn.commit()
if __name__ == '__main__':
    for id_d in get_id_for_14():
        print('id' + str(id_d['id']))
        if get_content_id_to_ext(id_d['id'])==None:
            update_14_to_media_type_4(id_d['id'])
        else:
            update_14_to_media_type_1(id_d['id'])